package com.ruoyi.system.domain;

import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.entity.YhMember;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseIdEntity;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;

/**
 * 佣金记录对象 yh_commission_record
 * 
 * @author ruoyi
 * @date 2023-06-06
 */
@Data
@ApiModel(value = "YhCommissionRecord", description = "佣金记录对象")
public class YhCommissionRecord extends BaseIdEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    @ApiModelProperty("id")
    private String id;

    /** 用户Id */
    @Excel(name = "用户Id")
    @ApiModelProperty("用户Id")
    private String memberId;

    /** 邀请用户ID */
    @Excel(name = "邀请用户ID")
    @ApiModelProperty("邀请用户ID")
    private String childMemberId;

    /** 佣金来源（海报分享：POSTER_SHARING） */
    @Excel(name = "佣金来源", readConverterExp = "海=报分享：POSTER_SHARING")
    @ApiModelProperty("佣金来源（海报分享：POSTER_SHARING）")
    private String type;

    /** 佣金 */
    @Excel(name = "佣金")
    @ApiModelProperty("佣金")
    private Double commission;

    /** 充值等级 */
    @Excel(name = "充值等级")
    @ApiModelProperty("充值等级")
    private Integer memberLevel;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;


    /** 更新时间 */
    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public <T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> wrapper=new QueryWrapper<>();

        wrapper.eq(StringUtils.isNotEmpty(memberId),"member_id" , memberId);
        wrapper.eq(StringUtils.isNotEmpty(childMemberId),"child_member_id" , childMemberId);
        wrapper.eq(StringUtils.isNotEmpty(type),"type" , type);
        wrapper.eq(commission != null,"commission" , commission);
        wrapper.eq(memberLevel != null,"member_level" , memberLevel);

        wrapper.orderByDesc("create_time");
        return wrapper;
    }

}
